#!/bin/bash
#Get mib description by local file

MIBS_DIR="/usr/share/snmp/mibs"

while [ $# -gt 0 ]; do
	for file in $MIBS_DIR/*
	do
		cat $file | awk 'BEGIN{\
			do_print = 0;\
			ret = 1;\
		}\
		{\
			if ( ($1 ~ "'"$1"'") && ( ($2 ~ ".*-TYPE") || ($2 ~ ".*-GROUP") || ($2 ~ ".*-COMPLIANCE") || ( $2 ~ ".*-IDENTITY") ) && ( do_print == 0 ) )\
			{\
				do_print = 1;\
				ret = 0;\
			}\
			if ( ( $1 ~ "::=" ) && ( $2 ~ "{" ) && ( do_print == 1 ) ) \
			{\
				print $0;\
				do_print = 0;\
			}\
			if ( do_print == 1 ) \
			{\
				print $0;\
			}\
		}\
		END{\
			exit ret;\
		}'
		if [ $? -eq 0 ] ; then
			echo ""
			echo "Found in $file"
			echo ""
			break
		fi
	done
	shift
done
exit 0
